package com.steam.hw2;

import com.steam.hw1.Student;

import java.util.List;
import java.util.stream.Stream;

/**
 * @author bin
 * @date 2025 - 04 -08
 **/
public class MainTest {
    public static void main(String[] args) {
        //第一：定义数据源（集合、数据）
        Student[] list1 = {
                new Student("张三2", 18),
                new Student("李四3", 20),
                new Student("王五", 19),
                new Student("赵六3", 21),
                new Student("钱七2", 22),
                new Student("孙八", 23)};

        Student[] list2 = {
                new Student("张三", 18),
                new Student("李四", 20),
                new Student("王五2", 19),
                new Student("张六", 21),
                new Student("张七", 22),
                new Student("张八3", 23)
        };

        Stream<Student> listStream1 = Stream.of(list1);
        Stream<Student> listStream2 = Stream.of(list2);


        List<Student> collect1 = listStream1.filter(o -> o.getName().length() == 3).limit(3).toList();

        List<Student> collect2 = listStream2.filter(t -> t.getName().startsWith("张")).skip(2).toList();

        List<String> list= Stream.concat(collect1.stream(), collect2.stream()).map(Student::getName).toList();

        list.forEach(System.out::println);

    }
}
